﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using ShardingWTM.Models;


namespace ShardingWTM.HistoryLogs.ViewModels.MessageLogVMs
{
    public partial class MessageLogListVM : BasePagedListVM<MessageLog_View, MessageLogSearcher>
    {
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("MessageLog", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"HistoryLogs", dialogWidth: 800),
                this.MakeStandardAction("MessageLog", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "HistoryLogs", dialogWidth: 800),
                this.MakeStandardAction("MessageLog", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "HistoryLogs", dialogWidth: 800),
                this.MakeStandardAction("MessageLog", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "HistoryLogs", dialogWidth: 800),
                this.MakeStandardAction("MessageLog", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "HistoryLogs", dialogWidth: 800),
                this.MakeStandardAction("MessageLog", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "HistoryLogs", dialogWidth: 800),
                this.MakeStandardAction("MessageLog", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "HistoryLogs", dialogWidth: 800),
                this.MakeStandardAction("MessageLog", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "HistoryLogs"),
            };
        }


        protected override IEnumerable<IGridColumn<MessageLog_View>> InitGridHeader()
        {
            return new List<GridColumn<MessageLog_View>>{
                this.MakeGridHeader(x => x.Payload),
                this.MakeGridHeader(x => x.CreateTime).SetSort(),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<MessageLog_View> GetSearchQuery()
        {
            var query = DC.Set<MessageLog>()
                .Select(x => new MessageLog_View
                {
				    ID = x.ID,
                    Payload = x.Payload,
                    CreateTime = x.CreateTime,
                })
                .OrderBy(x => x.CreateTime);
            return query;
        }

    }

    public class MessageLog_View : MessageLog{

    }
}
